<template>
  <view class="painting-detail">
    <view class="header">
      <view class="back-btn" @click="goBack">←</view>
      <text class="title">绘画详情</text>
    </view>
    
    <view class="content">
      <view class="painting-image">
        <view class="image-placeholder">{{ painting.emoji }}</view>
      </view>
      
      <view class="painting-info">
        <text class="name">{{ painting.name }}</text>
        <text class="author">by {{ painting.author }}</text>
        <text class="description">{{ painting.description }}</text>
        
        <view class="stats">
          <view class="stat-item">
            <text class="label">点赞</text>
            <text class="value">{{ painting.likes }}</text>
          </view>
          <view class="stat-item">
            <text class="label">收藏</text>
            <text class="value">{{ painting.collections }}</text>
          </view>
          <view class="stat-item">
            <text class="label">分享</text>
            <text class="value">{{ painting.shares }}</text>
          </view>
        </view>
        
        <view class="tags">
          <text class="tag" v-for="tag in painting.tags" :key="tag">{{ tag }}</text>
        </view>
      </view>
      
      <view class="actions">
        <button class="btn btn-primary" @click="likePainting">
          {{ isLiked ? '取消点赞' : '点赞' }}
        </button>
        <button class="btn btn-secondary" @click="collectPainting">
          {{ isCollected ? '取消收藏' : '收藏' }}
        </button>
        <button class="btn btn-secondary" @click="sharePainting">分享</button>
      </view>
      
      <view class="related-paintings">
        <text class="section-title">相关作品</text>
        <view class="related-list">
          <view class="related-item" v-for="item in relatedPaintings" :key="item.id" @click="goToPainting(item)">
            <view class="related-image">{{ item.emoji }}</view>
            <text class="related-name">{{ item.name }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      painting: {
        id: 1,
        name: '梦幻星空',
        emoji: '🌌',
        description: '这是一幅充满想象力的艺术作品，描绘了浪漫的星空夜景。画面中繁星点点，银河横跨天际，营造出梦幻般的氛围。作品运用了丰富的色彩层次，从深蓝到紫色的渐变，展现了夜空的深邃与神秘。',
        author: 'AI艺术家',
        likes: 1250,
        collections: 89,
        shares: 156,
        tags: ['星空', '夜景', '梦幻', '艺术', 'AI创作']
      },
      relatedPaintings: [
        { id: 2, name: '春日花园', emoji: '🌸' },
        { id: 3, name: '未来城市', emoji: '🏙️' },
        { id: 4, name: '海洋深处', emoji: '🐠' }
      ],
      isLiked: false,
      isCollected: false
    }
  },
  
  onLoad(options) {
    // 根据传入的参数加载绘画详情
    if (options.id) {
      this.loadPaintingDetail(options.id)
    }
  },
  
  methods: {
    goBack() {
      uni.navigateBack()
    },
    
    loadPaintingDetail(id) {
      // 这里应该调用API加载绘画详情
      console.log('加载绘画详情:', id)
    },
    
    likePainting() {
      this.isLiked = !this.isLiked
      if (this.isLiked) {
        this.painting.likes++
      } else {
        this.painting.likes--
      }
    },
    
    collectPainting() {
      this.isCollected = !this.isCollected
      if (this.isCollected) {
        this.painting.collections++
      } else {
        this.painting.collections--
      }
    },
    
    sharePainting() {
      // 实现分享功能
      console.log('分享绘画')
    },
    
    goToPainting(item) {
      uni.navigateTo({
        url: `/pages/painting-detail/painting-detail?id=${item.id}`
      })
    }
  }
}
</script>

<style scoped>
.painting-detail {
  min-height: 100vh;
  background-color: var(--primary-bg);
  padding-bottom: 50px;
}

.header {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  background-color: var(--secondary-bg);
  border-bottom: 1px solid var(--border-color);
}

.back-btn {
  width: 40px;
  height: 40px;
  background-color: rgba(240, 217, 181, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent-color);
  margin-right: 16px;
  cursor: pointer;
}

.title {
  font-size: 24px;
  font-weight: bold;
  color: var(--text-primary);
}

.content {
  padding: 16px;
}

.painting-image {
  margin-bottom: 24px;
}

.image-placeholder {
  width: 100%;
  height: 300px;
  background-color: rgba(240, 217, 181, 0.1);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 124px;
}

.painting-info {
  margin-bottom: 24px;
}

.name {
  display: block;
  font-size: 28px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.author {
  display: block;
  font-size: 20px;
  color: var(--accent-color);
  margin-bottom: 16px;
}

.description {
  display: block;
  font-size: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.stats {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.label {
  font-size: 16px;
  color: var(--text-muted);
}

.value {
  font-size: 22px;
  font-weight: bold;
  color: var(--text-primary);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tag {
  padding: 6px 12px;
  background-color: rgba(240, 217, 181, 0.1);
  color: var(--accent-color);
  border-radius: 16px;
  font-size: 16px;
}

.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
}

.btn {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #333;
}

.btn-secondary {
  background-color: var(--secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.related-paintings {
  margin-bottom: 24px;
}

.section-title {
  display: block;
  font-size: 24px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.related-list {
  display: flex;
  gap: 16px;
  overflow-x: auto;
}

.related-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 80px;
  cursor: pointer;
}

.related-image {
  width: 60px;
  height: 60px;
  background-color: rgba(240, 217, 181, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.related-name {
  font-size: 16px;
  color: var(--text-secondary);
  text-align: center;
}
</style>
